package com.eulog.client;

import com.eulog.client.blackJack.BlackJack;
import com.eulog.client.blackJack.BlackJackPlayer;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class ParameterPanel extends HorizontalPanel{
	
	private TextBox textBoxTrialNumber;
	private Button buttonSubmit;
	
	private BlackJack blackJack;
	//private BlackJackPlayer targetPlayer;
	
	public ParameterPanel(BlackJack _blackJack, BlackJackPlayer player) {
		super();
		
		blackJack = _blackJack;
		//targetPlayer = player;
		
		textBoxTrialNumber = new TextBox();
		buttonSubmit = new Button("Submit",new ClickListener () {
			public void onClick(Widget sender) { 
				submit();
			}
		});
		
		init();
	}
	
	public void init() {
		add(new Label("Trial"));
		add(textBoxTrialNumber);
		add(buttonSubmit);
	}
	
	public void submit() {
		
		String stringTrialNumber = textBoxTrialNumber.getText();		
		int trialNumber = Integer.valueOf(stringTrialNumber);
		
		if(trialNumber>0) {
		  for(int i=0; i<trialNumber;i++) {
			  blackJack.play();
			  RootPanel.get().add(new Label(blackJack.toStringCurrentGame()+blackJack.getCurrentDecks().getBlackJackStrategy()));
		  }
		}
	}
}
